package com.mobileares.midp.widgets.client.panel;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;
import com.mobileares.midp.widgets.client.common.DecorateBar;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-3-17
 * Time: 14:38:34
 * To change this template use File | Settings | File Templates.
 */
public class DecoratePanel extends Composite {
    private FlowPanel panel;
//    private DecorateBar main;
    private SimplePanel main;


    public SimplePanel getContainer() {
        return main;
    }

    public DecoratePanel() {
        panel = new FlowPanel();
        init();
        initWidget(panel);
    }

    public void setHeight(int height) {
        main.setHeight(height - 24 + "px");       //padding+top+bottom
    }

    private void init() {
        DecorateBar top = new DecorateBar("panel-decorate-top");
//        main = new DecorateBar("panel-decorate-main");
        main = new SimplePanel();
//        main.setHeight("100%");
        main.setStyleName("panel-decorate-main");

        DecorateBar bottom = new DecorateBar("panel-decorate-bottom");

        panel.add(top);
        panel.add(main);
        panel.add(bottom);
    }

    public void addWidget(Widget widget) {
//        main.getMain().setWidget(widget);
        main.setWidget(widget);
    }

//    /**
//     * This method is called immediately after a widget becomes attached to the
//     * browser's document.
//     */
//    @Override
//    protected void onLoad() {
//        if (autoHeight)
//            adopt();
//    }

//    public void adopt() {
//        main.setHeight(main.getOffsetHeight() + "px");
//
//    }
}
